import request from '/@/utils/request';

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 *
 * 登录api接口集合
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 */

const userApi = {
	Logout: '/api/auth/logout',
	ForgePassword: '/api/auth/forge-password',
	Register: '/api/auth/register',
	SendSms: '/api/account/sms',
	RequestLogin: '/api/Login/JWTToken',
	GetInfoByToken: '/api/User/getInfoByToken',
	SendSmsErr: '/api/account/sms_err',
};

/**
 * 登录api接口集合
 * @method signIn 用户登录
 * @method signOut 用户退出登录
 */
export function useLoginApi() {
	return {
		signIn: (params: object) => {
			return request({
				url: userApi.RequestLogin,
				method: 'post',
				data: params,
			});
		},
		signOut: (params: object) => {
			return request({
				url: userApi.Logout,
				method: 'post',
				data: params,
				headers: {
					'Content-Type': 'application/json;charset=UTF-8'
				}
			});
		},
		getSmsCaptcha (parameter : object) {
			return request({
				url: userApi.SendSms,
				method: 'post',
				data: parameter
			})
		},
		getUserByToken (parameter : object) {
			return request({
				url: userApi.GetInfoByToken,
				method: 'get',
				params: parameter
			})
		},
	};
}





